package com.seata.core.utils;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author 蚂蚁会花呗
 * @date 2021/6/25 14:27
 */
public class IpAddressUtils {

    /**
     * 获取IP地址
     * @return
     */
    public static String getIp() {
        InetAddress address = null;
        try {
            address = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return address.getHostAddress();
    }

    //获取当前url 路径
    public static String getIpUrl(String port){
        return "http://" + getIp() + ":" + port;
    }


}
